# coding=utf-8
import pika


class SendLog():
    def __init__(self,host='localhost'):
        self.connection = pika.BlockingConnection(pika.ConnectionParameters(host=host))
        self.channel = self.connection.channel()
        self.channel.exchange_declare(exchange='log', exchange_type='topic')

    def sendLog(self, message, type=''):
        self.channel.basic_publish(exchange='log', routing_key=type, body=message)

    def close(self):
        self.connection.close()

if __name__ == '__main__':
    send = SendLog()
    send.sendLog("the log from send")
    send.close()
    print "the end"